﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using OnlineFamilyCalendar.UI.Presentation.Views;
using OnlineFamilyCalendar.UI.Presentation;

namespace OnlineFamilyCalendar.UI.Web
{
    public partial class Register : System.Web.UI.Page, IRegisterView
    {
        private RegisterPresenter presenter;

        protected void Page_Load(object sender, EventArgs e)
        {
            presenter = new RegisterPresenter(this);
            if (Page.Request.QueryString["Id"] != null)
                presenter.ActivateUser(Page.Request.QueryString["Id"]);	
        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            presenter.Register();
        }

        public string Loginname
        {
            get { return txtLoginname.Text; }
        }

        public string Password
        {
            get { return txtPassword.Text; }
        }

        public string RepeatedPassword
        {
            get { return txtPasswordRepeat.Text; }
        }

        public string EmailAddress
        {
            get { return txtEmailAddress.Text; }
        }

        public string RegisterUrl
        {
            set 
            {
                string url = HttpContext.Current.Request.Url + "?Id={0}";
                lnkRegisterUrl.NavigateUrl = String.Format(url, HttpUtility.UrlEncode(value)); 
            }
        }

        public string RegisterText
        {
            set { lnkRegisterUrl.Text = value; }
        }
    }
}